package com.demo.util;


import org.apache.commons.lang3.StringUtils;

/**
 * 国家枚举
 */
public enum Country {
    DEFAULT_COUNTRY(9999,"","","其他"),
    ANGOLA(1, "AO", "00244", "安哥拉"),
    AFGHANISTAN(2, "AF", "0093", "阿富汗"),
    ALBANIA(3, "AL", "00355", "阿尔巴尼亚"),
    ALGERIA(4, "DZ", "00213", "阿尔及利亚"),
    ANDORRA(5, "AD", "00376", "安道尔共和国"),
    ANGUILLA(6, "AI", "001264", "安圭拉岛"),
    ANTIGUA_AND_BARBUDA(7, "AG", "001268", "安提瓜和巴布达"),
    ARGENTINA(8, "AR", "0054", "阿根廷"),
    ARMENIA(9, "AM", "00374", "亚美尼亚"),
    ASCENSION(10, "AC", "00247", "阿森松"),
    AUSTRALIA(11, "AU", "0061", "澳大利亚"),
    AUSTRIA(12, "AT", "0043", "奥地利"),
    AZERBAIJAN(13, "AZ", "00994", "阿塞拜疆"),
    BAHAMAS(14, "BS", "001242", "巴哈马"),
    BAHRAIN(15, "BH", "00973", "巴林"),
    BANGLADESH(16, "BD", "00880", "孟加拉国"),
    BARBADOS(17, "BB", "001246", "巴巴多斯"),
    BELARUS(18, "BY", "00375", "白俄罗斯"),
    BELGIUM(19, "BE", "0032", "比利时"),
    BELIZE(20, "BZ", "00501", "伯利兹"),
    BENIN(21, "BJ", "00229", "贝宁"),
    BERMUDA(22, "BM", "001441", "百慕大群岛"),
    BOLIVIA(23, "BO", "00591", "玻利维亚"),
    BOTSWANA(24, "BW", "00267", "博茨瓦纳"),
    BRAZIL(25, "BR", "0055", "巴西"),
    BRUNEI(26, "BN", "00673", "文莱"),
    BULGARIA(27, "BG", "00359", "保加利亚"),
    BURKINA_FASO(28, "BF", "00226", "布基纳法索"),
    BURMA(29, "MM", "0095", "缅甸"),
    BURUNDI(30, "BI", "00257", "布隆迪"),
    CAMEROON(31, "CM", "00237", "喀麦隆"),
    CANADA(32, "CA", "001", "加拿大"),
    CAYMAN_ISLANDS(33, "KY", "001345", "开曼群岛"),
    CENTRAL_AFRICAN_REPUBLIC(34, "CF", "00236", "中非共和国"),
    CHAD(35, "TD", "00235", "乍得"),
    CHILE(36, "CL", "0056", "智利"),
    CHINA(37, "CN", "0086", "中国"),
    COLOMBIA(38, "CO", "0057", "哥伦比亚"),
    CONGO(39, "CG", "00243", "刚果"),
    COOK_ISLANDS(40, "CK", "00682", "库克群岛"),
    COSTA_RICA(41, "CR", "00506", "哥斯达黎加"),
    CUBA(42, "CU", "0053", "古巴"),
    CYPRUS(43, "CY", "00357", "塞浦路斯"),
    CZECH_REPUBLIC(44, "CZ", "00420", "捷克"),
    DENMARK(45, "DK", "0045", "丹麦"),
    DJIBOUTI(46, "DJ", "00253", "吉布提"),
    DOMINICAN_REPUBLIC(47, "DO", "001809", "多米尼加共和国"),
    ECUADOR(48, "EC", "00593", "厄瓜多尔"),
    EGYPT(49, "EG", "0020", "埃及"),
    El_SALVADOR(50, "SV", "00503", "萨尔瓦多"),
    ESTONIA(51, "EE", "00372", "爱沙尼亚"),
    ETHIOPIA(52, "ET", "00251", "埃塞俄比亚"),
    FIJI(53, "FJ", "00679", "斐济"),
    FINLAND(54, "FI", "00358", "芬兰"),
    FRANCE(55, "FR", "0033", "法国"),
    FRENCH_GUIANA(56, "GF", "00594", "法属圭亚那"),
    GABON(57, "GA", "00241", "加蓬"),
    GAMBIA(58, "GM", "00220", "冈比亚"),
    GEORGIA(59, "GE", "00995", "格鲁吉亚"),
    GERMANY(60, "DE", "0049", "德国"),
    GHANA(61, "GH", "00233", "加纳"),
    GIBRALTAR(62, "GI", "00350", "直布罗陀"),
    GREECE(63, "GR", "0030", "希腊"),
    GRENADA(64, "GD", "001473", "格林纳达"),
    GUAM(65, "GU", "001671", "关岛"),
    GUATEMALA(66, "GT", "00502", "危地马拉"),
    GUINEA(67, "GN", "00224", "几内亚"),
    GUYANA(68, "GY", "00592", "圭亚那"),
    HAITI(69, "HT", "00509", "海地"),
    HONDURAS(70, "HN", "00504", "洪都拉斯"),
    HONG_KONG(71, "HK", "00852", "中国香港"),
    HUNGARY(72, "HU", "0036", "匈牙利"),
    ICELAND(73, "IS", "00354", "冰岛"),
    INDIA(74, "IN", "0091", "印度"),
    INDONESIA(75, "ID", "0062", "印度尼西亚"),
    IRAN(76, "IR", "0098", "伊朗"),
    IRAQ(77, "IQ", "00964", "伊拉克"),
    IRELAND(78, "IE", "00353", "爱尔兰"),
    ISRAEL(79, "IL", "00972", "以色列"),
    ITALY(80, "IT", "0039", "意大利"),
    IVORY_COAST(81, "CI", "00225", "科特迪瓦"),
    JAMAICA(82, "JM", "001876", "牙买加"),
    JAPAN(83, "JP", "0081", "日本"),
    JORDAN(84, "JO", "00962", "约旦"),
    CAMBODIA(85, "KH", "00855", "柬埔寨"),
    KAZAKHSTAN(86, "KZ", "007", "哈萨克斯坦"),
    KENYA(87, "KE", "00254", "肯尼亚"),
    KOREA(88, "KR", "0082", "韩国"),
    KUWAIT(89, "KW", "00965", "科威特"),
    KYRGYZSTAN(90, "KG", "00996", "吉尔吉斯坦"),
    LAOS(91, "LA", "00856", "老挝"),
    LATVIA(92, "LV", "00371", "拉脱维亚"),
    LEBANON(93, "LB", "00961", "黎巴嫩"),
    LESOTHO(94, "LS", "00266", "莱索托"),
    LIBERIA(95, "LR", "00231", "利比里亚"),
    LIBYA(96, "LY", "00218", "利比亚"),
    LIECHTENSTEIN(97, "LI", "00423", "列支敦士登"),
    LITHUANIA(98, "LT", "00370", "立陶宛"),
    LUXEMBOURG(99, "LU", "00352", "卢森堡"),
    MACAO(100, "MO", "00853", "中国澳门"),
    MADAGASCAR(101, "MG", "00261", "马达加斯加"),
    MALAWI(102, "MW", "00265", "马拉维"),
    MALAYSIA(103, "MY", "0060", "马来西亚"),
    MALDIVES(104, "MV", "00960", "马尔代夫"),
    MALI(105, "ML", "00223", "马里"),
    MALTA(106, "MT", "00356", "马耳他"),
    MARIANA_ISLANDS(107, "MP", "00223", "马里亚那群岛"),
    MARTINIQUE(108, "MQ", "00596", "马提尼克"),
    MAURITIUS(109, "MU", "00230", "毛里求斯"),
    MEXICO(110, "MX", "0052", "墨西哥"),
    MOLDOVA(111, "MD", "00373", "摩尔多瓦"),
    MONACO(112, "MC", "00377", "摩纳哥"),
    MONGOLIA(113, "MN", "00976", "蒙古"),
    MONTSERRAT(114, "MS", "001664", "蒙特塞拉特岛"),
    MOROCCO(115, "MA", "00212", "摩洛哥"),
    MOZAMBIQUE(116, "MZ", "00258", "莫桑比克"),
    NAMIBIA(117, "NA", "00264", "纳米比亚"),
    NAURU(118, "NR", "00674", "瑙鲁"),
    NEPAL(119, "NP", "00977", "尼泊尔"),
    NETHERIANDS_ANTILLES(120, "　", "00599", "荷属安的列斯"),
    NETHERLANDS(121, "NL", "0031", "荷兰"),
    NEW_ZEALAND(122, "NZ", "0064", "新西兰"),
    NICARAGUA(123, "NI", "00505", "尼加拉瓜"),
    NIGER(124, "NE", "00227", "尼日尔"),
    NIGERIA(125, "NG", "00234", "尼日利亚"),
    NORTH_KOREA(126, "KP", "00850", "朝鲜"),
    NORWAY(127, "NO", "0047", "挪威"),
    OMAN(128, "OM", "00968", "阿曼"),
    PAKISTAN(129, "PK", "0092", "巴基斯坦"),
    PANAMA(130, "PA", "00507", "巴拿马"),
    PAPUA_NEW_GUINEA(131, "PG", "00675", "巴布亚新几内亚"),
    PARAGUAY(132, "PY", "00595", "巴拉圭"),
    PERU(133, "PE", "0051", "秘鲁"),
    PHILIPPINES(134, "PH", "0063", "菲律宾"),
    POLAND(135, "PL", "0048", "波兰"),
    FRENCH_POLYNESIA(136, "PF", "00689", "法属玻利尼西亚"),
    PORTUGAL(137, "PT", "00351", "葡萄牙"),
    PUERTO_RICO(138, "PR", "001", "波多黎各"),
    QATAR(139, "QA", "00974", "卡塔尔"),
    REUNION(140, "RE", "00262", "留尼旺"),
    ROMANIA(141, "RO", "0040", "罗马尼亚"),
    RUSSIA(142, "RU", "007", "俄罗斯"),
    SAINT_VINCENT(144, "VC", "001784", "圣文森特岛"),
    SAMOA_EASTERN(145, "WS", "00684", "东萨摩亚(美)"),
    SAMOA_WESTERN(146, "WS", "00685", "西萨摩亚"),
    SAN_MARINO(147, "SM", "00378", "圣马力诺"),
    SAO_TOME_AND_PRINCIPE(148, "ST", "00239", "圣多美和普林西比"),
    SAUDI_ARABIA(149, "SA", "00966", "沙特阿拉伯"),
    SENEGAL(150, "SN", "00221", "塞内加尔"),
    SEYCHELLES(151, "SC", "00248", "塞舌尔"),
    SIERRA_LEONE(152, "SL", "00232", "塞拉利昂"),
    SINGAPORE(153, "SG", "0065", "新加坡"),
    SLOVAKIA(154, "SK", "00421", "斯洛伐克"),
    SLOVENIA(155, "SI", "00386", "斯洛文尼亚"),
    SOLOMON_ISLANDS(156, "SB", "00677", "所罗门群岛"),
    SOMALIA(157, "SO", "00252", "索马里"),
    SOUTH_AFRICA(158, "ZA", "0027", "南非"),
    SPAIN(159, "ES", "0034", "西班牙"),
    SRI_LANKA(160, "LK", "0094", "斯里兰卡"),
    ST_LUCIA(161, "LC", "001758", "圣卢西亚"),
    ST_VINCENT(162, "VC", "001784", "圣文森特"),
    SUDAN(163, "SD", "00249", "苏丹"),
    SURINAME(164, "SR", "00597", "苏里南"),
    SWAZILAND(165, "SZ", "00268", "斯威士兰"),
    SWEDEN(166, "SE", "0046", "瑞典"),
    SWITZERLAND(167, "CH", "0041", "瑞士"),
    SYRIA(168, "SY", "00963", "叙利亚"),
    TAIWAN(169, "TW", "00886", "中国台湾"),
    TAJIKISTAN(170, "TJ", "00992", "塔吉克斯坦"),
    TANZANIA(171, "TZ", "00255", "坦桑尼亚"),
    THAILAND(172, "TH", "0066", "泰国"),
    TOGO(173, "TG", "00228", "多哥"),
    TONGA(174, "TO", "00676", "汤加"),
    TRINIDAD_AND_TOBAGO(175, "TT", "001868", "特立尼达和多巴哥"),
    TUNISIA(176, "TN", "00216", "突尼斯"),
    TURKEY(177, "TR", "0090", "土耳其"),
    TURKMENISTAN(178, "TM", "00993", "土库曼斯坦"),
    UGANDA(179, "UG", "00256", "乌干达"),
    UKRAINE(180, "UA", "00380", "乌克兰"),
    UNITED_ARAB_EMIRATES(181, "AE", "00971", "阿拉伯联合酋长国"),
    UNITED_KINGDOM(182, "GB", "0044", "英国"),
    UNITED_STATES_OF_AMERICA(183, "US", "001", "美国"),
    URUGUAY(184, "UY", "00598", "乌拉圭"),
    UZBEKISTAN(185, "UZ", "00998", "乌兹别克斯坦"),
    VENEZUELA(186, "VE", "0058", "委内瑞拉"),
    VIETNAM(187, "VN", "0084", "越南"),
    YEMEN(188, "YE", "00967", "也门"),
    YUGOSLAVIA(189, "YU", "00338", "南斯拉夫"),
    ZIMBABWE(191, "ZW", "00263", "津巴布韦"),
    ZAIRE(192, "CD", "00243", "刚果民主共和国"),
    ZAMBIA(193, "ZM", "00260", "赞比亚"),
    ARUBA(194, "AW", "00297", "阿鲁巴"),
    AUSTRALIAN_OVERSEA_STERRITORIES(195, " ", "00672", "澳大利亚海外领地"),
    BHUTAN(196, "BT", "00975", "不丹"),
    BOSNIA_AND_HERZEGOVINA(197, "BA", "00387", "波斯尼亚和黑塞哥维那"),
    CAPE_VERDE(198, "CV", "00238", "佛得角"),
    COMOROS_ISLANDS(199, "KM", "00269", "科摩罗群岛"),
    CROATIA(200, "HR", "00385", "克罗地亚"),
    DIEGO_GARCIA(201, "DG", "00246", "迭戈加西亚群岛"),
    EAST_TIMOR(202, "TL", "00670", "东帝汶"),
    EQUATORIAL_GUINEA(203, "GQ", "00240", "赤道几内亚"),
    ERITREA(204, "ER", "00291", "厄立特里亚"),
    FALKLAND_ISLANDS(205, "FK", "00500", "福克兰群岛"),
    FAROE_ISLANDS(206, "FO", "00298", "法罗群岛"),
    GREENLAND(207, "GL", "00299", "格陵兰岛"),
    GUADELOUPE(208, "GP", "00590", "瓜德罗普"),
    GUINEA_BISSAU(209, "GW", "00245", "几内亚比绍"),
    KIRIBATI(210, "KI", "00686", "基里巴斯"),
    MACEDONIA(211, "MK", "00389", "北马其顿"),
    MARSHALL_ISLANDS(212, "MH", "00692", "马绍尔群岛"),
    MAURITANIA(213, "MR", "00222", "毛里塔尼亚"),
    MICRONESIA(214, "FM", "00691", "密克罗尼西亚"),
    MONTENEGRO(215, "ME", "00382", "黑山"),
    NEW_CALEDONIA(216, "NC", "00687", "新喀里多尼亚"),
    NIUE(217, "NU", "00683", "纽埃岛"),
    PALAU(218, "PW", "00680", "帕劳"),
    PALESTINE(219, "PS", "00970", "巴勒斯坦"),
    RWANDA(220, "RW", "00250", "卢旺达"),
    ST_HELENA(221, "SH", "00290", "圣赫勒拿岛"),
    SAINT_PIERRE_AND_MIQUELON(222, "PM", "00508", "圣皮埃尔和密克隆群岛"),
    SERBIA(223, "RS", "00381", "塞尔维亚"),
    TOKELAU(224, "TK", "00690", "托克劳群岛"),
    TUVALU(225, "TV", "00688", "图瓦卢"),
    VANUATU(226, "VU", "00678", "瓦努阿图"),
    VATICAN_CITY(227, "VA", "00379", "梵蒂冈城"),
    WALLIS_AND_FUTUNA(228, "WF", "00681", "瓦利斯和富图纳"),
    BRITISH_VIRGIN_ISLANDS(229, "VG", "001284", "英属维尔京群岛"),
    EMIRATE_OF_DUBAI(230, " ", "009714", "迪拜酋长国"),
    JERSEY(231, "JE", "0044", "泽西"),
    DOMINICA(232, "DM", "001767", "多米尼克国"),
    SAINT_KITTS_AND_NEVIS(233, "KN", "001869", "圣基茨和尼维斯"),
    KOSOVO(234, "XK", "00383", "科索沃"),
    ISLE_OF_MAN(235, "IM", "00441624", "马恩岛"),
    SOUTH_SUDAN(236, "SS", "00211", "南苏丹"),

    ALAND_ISLANDS(237, "AX", "0035818", "奥兰群岛"),
    AMERICAN_SAMOA(238, "AS", "001684", "美属萨摩"),
    SINT_EUSTATIUS_AND_SABA(239, "BQ", "00599", "荷兰加勒比区"),
    BOUVET_ISLAND(240, "BV", "0055", "布维岛"),
    CHRISTMAS_ISLAND(241, "CX", "006189164", "圣诞岛"),
    COCOS_KEELING_ISLANDS(242, "CC", "006189162", "科科斯(基林)群岛"),
    CURACAO(243, "CW", "005999", "库拉索"),
    FRENCH_SOUTHERN_TERRITORIES(244, "TF", "0033", "法属南部领土"),
    GAZA_STRIP(245, " ", "00970", "加沙地带"),
    GUERNSEY(246, "GG", "00441481", "根西岛"),
    LABUAN(247, " ", "006087", "纳闽"),
    MAYOTTE(248, "YT", "00262", "马约特"),
    NORFOLK_ISLAND(249, "NF", "006723", "诺福克岛"),
    SAINT_BARTHÉLEMY(250, "BL", "00590", "圣巴泰勒米岛"),
    SAINT_MARTIN_FRENCH_PART(251, "MF", "0059033", "圣马丁(法国)"),
    SINT_MAARTEN_DUTCH_PART(252, "SX", "001721", "圣马丁(荷兰)"),
    SOUTH_GEORGIA_SOUTH_SANDWICH(253, "GS", "00500", "南乔治亚岛和南桑德韦奇岛"),
    SVALBARD_AND_JAN_MAYEN(254, "SJ", "0047", "斯瓦尔巴群岛和扬马延岛"),
    TURKS_AND_CAICOS_ISLANDS(255, "TC", "001649", "特克斯和凯科斯群岛"),
    UNITED_STATES_MINOR_OUTLYING_ISLAND(256, "UM", "001246", "美国本土外小岛屿"),
    VIRGIN_ISLANDS_US(257, "VI", "001340", "美属维尔京群岛"),
    WESTERN_SAHARA(258, "EH", "00212", "西撒哈拉");




    private Integer id;
    private String keyword;
    private String code;
    private String name;

    Country(Integer id, String keyword, String code, String name) {
        this.id = id;
        this.keyword = keyword;
        this.code = code;
        this.name = name;
    }

    public static Country findByCode(String code) {
        for (Country country : Country.values()) {
            if (country.getCode().equals(code)) {
                return country;
            }
        }

        return null;
    }

    public static Country findById(Integer id) {
        for (Country country : Country.values()) {
            if (country.getId().equals(id)) {
                return country;
            }
        }
        return null;
    }

    /**
     * 通过keyword查国家枚举
     * @param keyword
     * @return
     */
    public static Country findByKeyword(String keyword) {
        if(StringUtils.isBlank(keyword)){
            return null;
        }
        for (Country country : Country.values()) {
            if (country.getKeyword().equalsIgnoreCase(keyword)) {
                return country;
            }
        }
        return null;
    }

    public Integer getId() {
        return id;
    }

    public String getKeyword() {
        return keyword;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }


}
